﻿using System.Collections.Generic;
using XmlStudio.DataLayer;
using System.Xml;
using System.Diagnostics.Contracts;

namespace XmlStudio.Interfaces {
    /// <summary>
    /// Defines methods for all implementations of classes manipulating with huge xml documents.
    /// </summary>
    //[ContractClass(typeof(BigXmlDocumentContract))]
    internal interface IBigXmlDocument {
        #region Properties
        /// <summary>
        /// Gets or sets the root element of the document.
        /// </summary>
        BigXmlNode Root { get; set; }

        /// <summary>
        /// Gets the <see cref="IBigXmlReader"/> associated with the current document.
        /// </summary>
        IBigXmlReader Reader { get; }
        #endregion

        #region Methods
        void RemoveRootNode();

        /// <summary>
        /// Gets child nodes of the specified node.
        /// </summary>
        /// <param name="parent">Parent node of which to get the child nodes.</param>
        /// <param name="range">Range of child nodes to get.</param>
        /// <returns>Collection of child nodes.</returns>
        IEnumerable<BigXmlNodeInternal> GetChildNodes(BigXmlNodeInternal parent, string range);

        /// <summary>
        /// Gets the collection of child nodes of the specified node for the specified range.
        /// </summary>
        /// <param name="parent">Parent node of which to get the child nodes.</param>
        /// <param name="range">Range of child nodes to get.</param>
        /// <returns>Collection of child nodes.</returns>
        IEnumerable<BigXmlNodeInternal> GetChildNodes(BigXmlNodeInternal parent, IEnumerable<int> range);

        /// <summary>
        /// Gets child nodes of the node at the specified address.
        /// </summary>
        /// <param name="address">Address of the parent node which child nodes to get.</param>
        /// <param name="range">Range of child nodes to get. Specify empty string to get all child nodes.</param>
        /// <returns>Collection of <see cref="BigXmlNode"/>.</returns>
        IEnumerable<BigXmlNodeInternal> GetChildNodes(int[] address, string range);

        /// <summary>
        /// Gets the document type of the document if exists.
        /// </summary>
        /// <returns><see cref="XmlDocumentType"/> for current document or null if there is no doc type.</returns>
        XmlDocumentType GetDocumentType();

        /// <summary>
        /// Writes document type to the <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="documentType">Document type to write.</param>
        /// <param name="writer">Destination where to write.</param>
        void WriteXmlDocumentType(XmlDocumentType documentType, XmlWriter writer);
        #endregion
    }
}